<script type="text/javascript" src="__PUBLIC__/js/plugins/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
  var uploader_middle = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: ['cover_btn_middle'], // 上传按钮
        url: "__APP__/Tian/Uploadreal/cover_img/id/{$id}/utype/{$utype}", //远程上传地址
        flash_swf_url: 'plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: 'plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '50mb', //最大上传文件大小（格式100b, 10kb, 50mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        multipart_params: {
            code: 'identity',
        },
        init: {
            FilesAdded: function(up, files) { //文件上传前

                var item = "";
                plupload.each(files, function(file) { //遍历文件
                    item += "<div class='progress' id=" + file['id'] + "><span class='bar'></span><span class='percent'>0%</span></div>";
                });
                $("#img_area_middle").html(item)
                uploader_middle.start();

            },
            UploadProgress: function(up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发

                var data = eval("(" + info.response + ")");//解析返回的json数据
                if (data.error != '') {
                    alert(data.error);
                    $("#img_area_middle").html("<img id='cover_img_middle' class='cover_img' src='__PUBLIC__/images/cover.jpg' alt='封面'><input name='logo_middle' value='' autocomplete='off' type='hidden'>");
                } else {
                    $("#" + file.id).html("<input type='hidden'name='logo_middle' value='" + data.src + "'/><img class='img_common'  src='__APP__/" + data.src + "'/>");//追加图片
                }
            },
            Error: function(up, err) { //上传出错的时候触发
                alert(err.message);
            }
        }
    });
    uploader_middle.init();
    var uploader_big = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: ['cover_btn_big'], // 上传按钮
        url: "__APP__/Tian/Uploadreal/cover_img/id/{$id}/utype/{$utype}", //远程上传地址
        flash_swf_url: 'plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: 'plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '50mb', //最大上传文件大小（格式100b, 10kb, 50mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        multipart_params: {
            code: 'identity',
        },
        init: {
            FilesAdded: function(up, files) { //文件上传前

                var item = "";
                plupload.each(files, function(file) { //遍历文件
                    item += "<div class='progress' id=" + file['id'] + "><span class='bar'></span><span class='percent'>0%</span></div>";
                });
                $("#img_area_big").html(item)
                uploader_big.start();

            },
            UploadProgress: function(up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发

                var data = eval("(" + info.response + ")");//解析返回的json数据
                if (data.error != '') {
                    alert(data.error);
                    $("#img_area_big").html("<img id='cover_img_big' class='cover_img' src='__PUBLIC__/images/cover.jpg' alt='封面'><input name='logo_big' value='' autocomplete='off' type='hidden'>");
                } else {
                    $("#" + file.id).html("<input type='hidden'name='logo_big' value='" + data.src + "'/><img class='img_common'  src='__APP__/" + data.src + "'/>");//追加图片
                }
            },
            Error: function(up, err) { //上传出错的时候触发
                alert(err.message);
            }
        }
    });
    uploader_big.init();


</script>

